package com.example.jdk7;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

public class java7Test2 {

    public static final String url = "jdbc:mysql://127.0.0.1/student";
    public static final String name = "com.mysql.jdbc.Driver";
    public static final String user = "root";
    public static final String password = "root";

    public static void main(String[] args) {

//        1. Connection，ResultSet 和Statement 都实现了Closeable 接口，所有在try-with-resources 语句中调
//        用，就可以自动关闭相关资源了

        Connection con = null;//获取连接;
        try {
            con = DriverManager.getConnection(url, user, password);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        try (
//                Class.forName("");//指定连接类
                Statement stmt = con.createStatement()
        ){

        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
